﻿package org.atk {
	
	import org.aswing.geom.IntDimension;
	import org.atk.components.ATreeGridView;
	import org.aswing.ASColor;
	import org.aswing.BorderLayout;
	import org.aswing.FlowLayout;
	import org.aswing.JButton;
	import org.aswing.JPanel;
	import org.aswing.JScrollPane;
	import org.aswing.JWindow;
	import org.aswing.event.*;
	import org.atk.components.treegridview.DefaultTreeGridViewRowData;
	import org.atk.components.treegridview.TreeGridViewItem;
	
	/**
	 * ...
	 * @author AeTky
	 */
	public class Application extends JWindow{
		
		private var tgView:ATreeGridView;
		private var tgView2:ATreeGridView;
		
		public function Application(){
			
			
			tgView = new ATreeGridView();
			tgView.setPreferredSize(new IntDimension(400,250));
			tgView2 = new ATreeGridView();
			
			tgView2.TgvRenderer = new MyRenderer();
			
			tgView2.setPreferredSize(new IntDimension(400,250));
			initTgView();
			
			var panel:JPanel = new JPanel(new FlowLayout());
			panel.setPreferredHeight(50);
			
/*			
			var btn:JButton = new JButton("test");
			btn.addEventListener(AWEvent.ACT, onBtnTestClick);	
			panel.append(btn);
*/			
			var fl:FlowLayout = new FlowLayout();
			
			//var spanel:JScrollPane = new JScrollPane(tgView);
			var mainPanel:JPanel = new JPanel(fl);
			
			mainPanel.append(tgView,FlowLayout.LEFT);
			mainPanel.append(tgView2,FlowLayout.LEFT);
			
			this.getContentPane().append(panel, BorderLayout.NORTH);
			this.getContentPane().append(mainPanel, BorderLayout.CENTER);
			
			this.show();
		}
		public function evtResize(w:Number,h:Number):void {
			this.setWidth(stage.stageWidth);
			this.setHeight(stage.stageHeight);
		}

		private function initTgView():void{
			tgView.addColumn("user", 150,true);
			tgView.addColumn("mail", 75,true);
			tgView.addColumn("telefon", 75);
			
			var emp:TreeGridViewItem = new TreeGridViewItem(new DefaultTreeGridViewRowData(["customers", "", ""]), true);
			emp.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Igor, Mike", "mm@cc.com", "1000-0000-0000"])));
			emp.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["John, Mike", "mm@cc.com", "2000-0000-0000"])));
			emp.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["John, John", "mm@cc.com", "3000-0000-0000"])));
			tgView.ROOT.append(emp);
			
			
			
			tgView2.addColumn("user", 150,true);
			tgView2.addColumn("telefon", 75,true,null,null,ASColor.getASColor(240,240,240));
			tgView2.addColumn("mail", 75);
			
			emp= new TreeGridViewItem(new MyCellData("PRIVAT",true), true);
			emp.append(new TreeGridViewItem(new MyCellData("Otto Schultze",false,"0000-0000")));
			emp.append(new TreeGridViewItem(new MyCellData("Mike Maus", false,null,"bal@wo.com")));
			emp.append(new TreeGridViewItem(new MyCellData("Tom Baum",false,"1111-1232544356","tom@baum.com")));
			tgView2.ROOT.append(emp);
			
			/*
			var cust:TreeGridViewItem= new TreeGridViewItem(new DefaultTreeGridViewRowData(["private", "", ""]), true);
			var frn:TreeGridViewItem =  new TreeGridViewItem(new DefaultTreeGridViewRowData(["Mike Hammer", "", ""]), true,true);
			
			
			
			cust.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Miller, Millmanman", "mm@cc.com", "1000-0000-0000"])));
			var a1:TreeGridViewItem =  new TreeGridViewItem(new DefaultTreeGridViewRowData(["thomas, tomtom", "mm@cc.com", "0100-0000-0000"]),true);
			cust.append(a1);
			cust.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Miller", "mm@cc.com", "0000-0000-0001"])));
			
			frn.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Text12, Mike", "mm@cc.com", "0000-0000-0000"])));
			frn.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Text13, Mike", "mm@cc.com", "0000-0000-0000"])));
			frn.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Text143, Mike", "mm@cc.com", "0000-0000-0000"])));
			
			a1.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Miller, Mike", "mm@cc.com", "0000-0000-0000"])));
			a1.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Miller, Mike", "mm@cc.com", "0000-0000-0000"])));
			a1.append(new TreeGridViewItem(new DefaultTreeGridViewRowData(["Miller, Mike", "mm@cc.com", "0000-0000-0000"])));
			
			tgView.ROOT.append(emp);
			tgView.ROOT.append(cust);
			tgView.ROOT.append(frn);
*/
		}
		
	}
	
}